home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 13 / AMIGAplus Sonderheft 13 (1998)(ICP)(DE)[!].iso / rexx / sofar.rexx < prev    next >
OS/2 REXX Batch file  |  1994-10-15  |  3KB  |  154 lines

  1. /*
  2.         $VER: SoFar (15 Oct 1994)
  3. */
  4.  
  5. ARG iNameCode
  6.  
  7. options results
  8.  
  9. /* Initialize */
  10. DataPath = "S:TimeKeep/"
  11.  
  12. if iNameCode = "" then do
  13.     Say ""
  14.     Say "ERROR: No Client Code"
  15.     Say ""
  16.     exit
  17. end
  18.  
  19. /* Read Time Data */
  20. if ~ open('Time', DataPath||iNameCode||".time", 'R') then do
  21.     Say ""
  22.     Say "ERROR: .time NOT FOUND"
  23.     Say ""
  24.     exit
  25. end
  26.  
  27. t = readln('Time')
  28. parse var t '"'Client.NameCode'","'Client.Name'"'
  29.  
  30. /* Collate */
  31. Projects = "|"; nProjects = 0 ; Expenses = 0; Work = 0
  32. do while ~eof('Time')
  33.     t = readln('Time')
  34.     parse var t '"'tType'","'tProject'",'tInfo
  35.  
  36.     if tInfo == "" then leave
  37.  
  38.     if index(Projects, "|"tProject"|") = 0 then do
  39.         /* Project not found */
  40.         Projects = Projects||tProject"|"
  41.         nProjects = nProjects + 1
  42.         Projects.nProjects.Name = tProject
  43.  
  44.         if tType = "T" then do
  45.             Projects.nProjects.count = 1
  46.             Expenses.nProjects.count = 0
  47.             end
  48.         else do
  49.             Projects.nProjects.count = 0
  50.             Expenses.nProjects.count = 1
  51.         end
  52.  
  53.         cProject = nProjects; n = 1
  54.         end
  55.     else do
  56.         /* Project exists */
  57.         do lp = 1 to nProjects
  58.             if Projects.lp.Name = tProject then leave
  59.         end
  60.         cProject = lp
  61.  
  62.         if tType = "T" then do
  63.             Projects.lp.count = Projects.lp.count + 1
  64.             n = Projects.lp.count
  65.             end
  66.         else do
  67.             Expenses.lp.count = Expenses.lp.count + 1
  68.             n = Expenses.lp.count
  69.         end
  70.     end
  71.  
  72.     if tType = "T" then do
  73.         Projects.cProject.n.Info = tInfo
  74.         Work = 1
  75.         end
  76.     else do
  77.         Expenses.cProject.n.Info = tInfo
  78.         Expenses = 1
  79.     end
  80. end
  81.  
  82. call close('Time')
  83.  
  84. if nProjects = 0 then do
  85.     Say ""
  86.     Say "ERROR: NO Logged Time or Expenses"
  87.     Say ""
  88.     exit
  89. end
  90.  
  91. /* Create Invoice */
  92.  
  93. Say ""
  94. Say Client.Name
  95.  
  96. /* Expenses */
  97. TotalExpenses = 0
  98. if Expenses then do
  99.     Say ""
  100.     Say "== EXPENSES ==========================="
  101.  
  102.     do lp = 1 to nProjects
  103.         if Expenses.lp.count = 0 then iterate
  104.  
  105.         Say Projects.lp.Name
  106.  
  107.         do lp2 = 1 to Expenses.lp.count
  108.             parse var Expenses.lp.lp2.Info '"'tInfo'","'tAmount'"'
  109.             Say "  "tInfo"  "tAmount
  110.             TotalExpenses = TotalExpenses + tAmount
  111.         end
  112.     end
  113.  
  114.     Say ""
  115.     Say "              TOTAL EXPENSES  $ "TotalExpenses
  116. end
  117.  
  118. /* Work Hours */
  119. Total = 0
  120. if Work then do
  121.     Say ""
  122.     Say "== WORK HOURS ========================="
  123.  
  124.     do lp = 1 to nProjects
  125.         if Projects.lp.count = 0 then iterate
  126.  
  127.         Say Projects.lp.Name
  128.  
  129.         HSubTotal = 0
  130.         do lp2 = 1 to Projects.lp.count
  131.             parse var Projects.lp.lp2.Info '"'tDate'","'tT1'","'tT2'","'tH'","'tRate'"'
  132.             HSubTotal = HSubTotal + tH
  133.         end
  134.  
  135.         SubTotal = trunc(HSubTotal * tRate + .5e-2, 2)
  136.  
  137.         Say "  "HSubTotal" @ $"tRate" / hour: "SubTotal
  138.         Total = Total + SubTotal
  139.     end
  140.  
  141.     Say ""
  142.     Say "                  TOTAL WORK  $ "Total
  143. end
  144.  
  145. Say ""
  146. Say "== TOTAL =============================="
  147.  
  148. Total = Total + TotalExpenses
  149. Say ""
  150. Say "                        TOTAL $ "Total
  151. Say ""
  152.  
  153. exit
  154.